<template>
  <div class="f-c">
    <div class="header">
      <div class="title">选择建设单位</div>
    </div>
    <SearchForm
      :search-list="searchList"
      :search-params="searchParams"
      @search="onSearch"
      @reset="onReset"
    />
    <el-form>
      <el-form-item style="text-align: right">
        <el-button type="primary" :disabled="!selectOptions.length" @click="onBatchSend(scope.row)">通知下发</el-button>
      </el-form-item>
    </el-form>
    <div class="table-box">
      <el-table
        v-loading="loading"
        height="100%"
        :data="tableData"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(255, 255, 255, 0.8)"
        @selection-change="onSelect"
      >
        <el-table-column v-for="item in columns" :key="item.prop" :prop="item.prop" :label="item.label" align="center" />
        <el-table-column label="操作" fixed="right" width="100px">
          <template slot-scope="scope">
            <el-button type="primary" @click="onEdit(scope.row)">组织参会</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-dialog
      title="建设单位详情"
      :visible.sync="dialogValue"
      width="600px"
      append-to-body
    >
      <el-form inline>
        <el-form-item label="建设单位名称">
          {{ currentDetail.departName }}
        </el-form-item>
        <el-form-item label="建设单位名称">
          {{ currentDetail.industryName }}
        </el-form-item>
        <el-form-item label="描述">
          {{ currentDetail.industryExpertise }}
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { http } from '@/api'
import crud from '@/mixins/crud'
export default {
  name: 'BuildDept',
  mixins: [crud],
  props: {
    currentDetail: Object
  },
  data() {
    return {
      request: {
        list: http.admin_engineering.build_dept
      },
      searchList: [
        {
          key: 'industryName',
          name: 'select',
          label: '行业',
          options: []
        },
        {
          key: 'departName',
          name: 'input',
          label: '建设单位'
        }
      ],
      searchParams: {
        industryName: '',
        departName: ''
      },
      columns: [
        { prop: 'departName', label: '建设单位名称' },
        { prop: 'industryName', label: '行业' }
      ]
    }
  },
  created() {
    http.meeting_apply.hangye().then(res => {
      this.searchList[0].options = res.data.map(el => {
        return {
          value: el,
          name: el
        }
      })
    })
  },
  methods: {
    getQueryParams() {
      const params = {
        pageNo: this.pageNo,
        pageSize: this.pageSize,
        projectId: this.currentDetail.id
      }
      if (!this.searchParams) return params
      for (const searchParamsKey in this.searchParams) {
        if (searchParamsKey === 'timeValue') {
          if (!this.searchParams[searchParamsKey] || !this.searchParams[searchParamsKey].length) {
            this.searchParams[searchParamsKey] = ['', '']
          }
          params['start'] = this.searchParams.timeValue[0] || undefined
          params['end'] = this.searchParams.timeValue[1] || undefined
        } else {
          params[searchParamsKey] = this.searchParams[searchParamsKey] === '' ? null : this.searchParams[searchParamsKey]
        }
      }
      return params
    },
    onBatchSend() {
      http.meeting_process.sendAccountProfessor(this.selectOptions1.map(el => el.id)).then(res => {
        this.$message.success(res.msg)
        this.getList1()
      })
    },
    onRead(row) {
      this.dialogValue = true
      this.currentDetail = row
    }
  }
}
</script>

<style scoped lang="scss">
</style>
